﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import Engine.Classes.*;
    import Engine.Managers.*;
    import Events.*;
    import Display.DialogUI.*;
    import Classes.util.*;
    import Display.*;
    import Modules.stats.types.*;

    public class StartUpDialogHelper {

        public function getCallback(_arg1:String):Function{
            if ((_arg1 in this)){
                return ((this[_arg1] as Function));
            };
            return (null);
        }
        public function visitGaGaFarm(_arg1:Array, _arg2):void{
            if (_arg2.button == GenericDialogView.YES){
                GlobalEngine.socialNetwork.redirect("xpromo.php?action=sendToFarmGaGa&source=announce", null, "_blank");
            };
        }
        public function xpromoButton(_arg1:Array, _arg2):void{
            var _local3:String;
            var _local4:String;
            if (_arg2.button == GenericDialogView.YES){
                if (_arg1.length > 0){
                    _local3 = _arg1[0];
                    _local4 = "_blank";
                    if (_arg1.length > 1){
                        _local4 = _arg1[1];
                    };
                    GlobalEngine.socialNetwork.redirect(_local3, null, _local4);
                };
            };
        }
        public function notifyGuide(_arg1:Array, _arg2):void{
            var _local3 = !((_arg1[0] == "false"));
            var _local4:String = (_arg1[1] as String);
            var _local5:String = ((_arg1.length > 2)) ? (_arg1[2] as String) : null;
            var _local6:Boolean = (((_arg2 is GenericPopupEvent)) && (((_arg2 as GenericPopupEvent).button == GenericDialogView.YES)));
            var _local7:Boolean = (((_local5 == null)) || ((Global.experimentManager.getVariant(_local5) > 0)));
            if (((!(_local3)) || (_local6))){
                Global.guide.notify(_local4);
            };
        }
        public function openPotatoesInMarket(_arg1:Array, _arg2):void{
            UI.displayCatalog("farming", "plot_sweetpotato", false);
        }
        public function openBlueberriesInMarket(_arg1:Array, _arg2):void{
            UI.displayCatalog("farming");
        }
        public function openTrainsInMarket(_arg1:Array, _arg2):void{
            Global.world.citySim.trainManager.scrollToTrainStation();
            Global.world.citySim.trainManager.showTrainScheduleCatalog();
        }
        public function mafiaXPromoRedirect(_arg1:Array, _arg2):void{
            if ((((_arg2 as GenericPopupEvent)) && (((_arg2 as GenericPopupEvent).button == GenericPopup.ACCEPT)))){
                GlobalEngine.socialNetwork.redirect("xpromo.php?action=sendToMafiaBrazil", null, "_blank");
            };
        }
        public function openMarketToNewItems(_arg1:Array, _arg2):void{
            if ((((_arg2 as GenericPopupEvent)) && (((_arg2 as GenericPopupEvent).button == GenericPopup.ACCEPT)))){
                UI.displayCatalog("new");
            };
        }
        public function scrollToAndActivateAnnouncer(_arg1:Array, _arg2):void{
            var _local3:String;
            if (_arg1.length > 0){
                _local3 = _arg1[0].toString();
                Global.world.citySim.announcerManager.scrollToAnnouncer(_local3);
            };
        }
        public function purchaseStarterPack(_arg1:Number):void{
            FrameManager.navigateTo(("money.php?fbcPopup=true&spVariant=" + _arg1));
        }
        public function purchaseStarterPack1(_arg1:Array, _arg2):void{
            this.handleStarterPackPurchase(_arg2, 1);
        }
        public function purchaseStarterPack2(_arg1:Array, _arg2):void{
            this.handleStarterPackPurchase(_arg2, 2);
        }
        public function purchaseStarterPack3(_arg1:Array, _arg2):void{
            this.handleStarterPackPurchase(_arg2, 3);
        }
        private function handleStarterPackPurchase(_arg1, _arg2:int):void{
            if ((((_arg1 as GenericPopupEvent)) && (((_arg1 as GenericPopupEvent).button == GenericPopup.ACCEPT)))){
                StatsManager.sample(100, StatsCounterType.DIALOG, StatsKingdomType.ANNOUNCEMENT, "click", (("AnnouncementStarterPack" + _arg2) + "_title"));
                this.purchaseStarterPack(_arg2);
            };
        }
        private function getCanCompleteHardwareStore(_arg1:WorldObject):Boolean{
            if (!(_arg1 is ConstructionSite)){
                return (false);
            };
            var _local2:ConstructionSite = (_arg1 as ConstructionSite);
            if (_local2.targetName != "bus_hardwarestore"){
                return (false);
            };
            if (_local2.currentState == ConstructionSite.STATE_AT_GATE){
                return (true);
            };
            return (false);
        }
        public function startHardwareStore(_arg1:Array, _arg2):void{
            var _local3:Array = Global.world.getObjectsByPredicate(this.getCanCompleteHardwareStore);
            var _local4:ConstructionSite;
            if (_local3.length == 1){
                _local4 = (_local3[0] as ConstructionSite);
                if (_local4.currentState == ConstructionSite.STATE_AT_GATE){
                    _local4.onPlayAction();
                    return;
                };
            };
            var _local5 = "qm_hardware1";
            var _local6:Object = Global.questManager.getQuestProgressByName(_local5);
            if (((_local6) && (!(Global.player.isQuestCompleted(_local5))))){
                Global.questManager.pumpActivePopup(_local5);
                return;
            };
        }
        public function startBakeryUpgrade(_arg1:Array, _arg2):void{
            if (!Global.questManager.hasSeenQuestIntro(Business.UPGRADE_QUEST_NAME)){
                Global.player.setSeenFlag(Business.UPGRADES_FLAG_INTRO);
                Global.questManager.pumpActivePopup(Business.UPGRADE_QUEST_NAME);
                Business.refreshAll();
            };
        }

    }
}//package Classes 
